#!/usr/bin/env python

# Copyright (C) 2008, 2009  Spencer Herzberg <spencer.herzberg@gmail.com>

# This file is part of GooeyStat

# GooeyStat is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QPixmap,QSplashScreen,QApplication
import gooeylib
from gooeylib.gooeystat import GooeyStat
from gooeylib import trace
import sys, optparse, logging, os.path
from pkg_resources import resource_filename


def main(inputfiles):
    
    app = QApplication(sys.argv)
    
    splash = QSplashScreen( QPixmap(resource_filename(__name__, "splash.png")),Qt.WindowStaysOnTopHint )
    splash.show()
    
    window = GooeyStat()
    window.show()
    
    for f in inputfiles:
        trace.mutter('Opening file %s', f)
        window.fileNew(f)
    splash.finish(window)
    
    app.exec_()

if __name__ == "__main__":
    parser = optparse.OptionParser()
    parser.add_option('-D', '-v', '--debug', 
                      dest='debug', default=False, action='store_true',
                      help='Print verbose information as you run.'
                     )
    options, args = parser.parse_args()

    if options.debug:
        trace.debug_on()
    
    main(args)
